package com.java.netty.nio.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @Author: Dgg
 * @Date: 2021/12/23 20:38
 */
public class TestServerInitializar extends ChannelInitializer<SocketChannel> {
	@Override
	protected void initChannel(SocketChannel ch) throws Exception {
		//向管道加入处理器

		//得到管道
		ChannelPipeline pipeline = ch.pipeline();
		System.out.println("初始化通道");
		//加入一个netty 提供的httpserverCode code => [code - decoder]
		// netty 提供的编解码 器
		pipeline.addLast("MyHttpServerCodec", new HttpServerCodec());
		//增加自定义 handler
		pipeline.addLast("MyTestHttpServerHandler", new TestHttpServerHandler());
	}
}
